import { get } from 'lodash-es'
import { BasicColumn } from '@/components/Table';
import { formatToDateTime } from '@/utils/dateUtil'

export const tableColumns: BasicColumn[] = [
  {
    title: '预约人',
    dataIndex: 'orderName',
    width: 90
  },
  {
    title: '联系电话',
    dataIndex: 'phone',
  },
  {
    title: '预约房间',
    dataIndex: 'room',
    width: 100
  },
  {
    title: '来源',
    dataIndex: 'source',
    width: 70,
    slots: { customRender: 'source' }
  },
  {
    title: '预约时间',
    dataIndex: 'orderDate',
    customRender: ({ record }) => {
      return formatToDateTime(record.orderDate)
    }
  },
  {
    title: '预约结束时间',
    dataIndex: 'orderEndDate',
    customRender: ({ record }) => {
      return formatToDateTime(record.orderEndDate)
    }
  },
  {
    title: '剩余时间',
    dataIndex: 'remainingTime',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 90,
    customRender: ({ record }) => {
      const target = orderStatusOptions.find(item => item.value === record.status);
      return get(target, 'label', '--')
    }
  }
]

export const orderStatusOptions = [
  {
    label: '待签到',
    value: '0'
  },
  {
    label: '计费中',
    value: '1'
  },
  {
    label: '取消',
    value: '2'
  }
]

export enum OrderStatusEnum {
  Unsign = '0',
  Signed = '1',
  Cancel = '2',
  Renewal = '3'
}

export const OrderSourceOptions = [
  {
    label: '大众',
    value: '1'
  },
  {
    label: '美团',
    value: '2'
  },
  {
    label: '抖音',
    value: '3'
  }
]